/**
 * Copyright (C) 2018-2019
 * All rights reserved, Designed By www.joolun.com
 * 注意：
 * 本软件为www.joolun.com开发研制，项目使用请保留此说明
 */
package com.joolun.web.api;

import com.joolun.common.core.domain.AjaxResult;
import com.joolun.mall.entity.PhoneList;
import com.joolun.mall.service.PhoneListService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 电话
 */
@Slf4j
@RestController
@AllArgsConstructor
@RequestMapping("/weixin/api/ma/phoneList")
@Api(value = "phoneList", tags = "电话")
public class PhoneListApi {

	@Autowired
	private PhoneListService phoneListService;

	/**
	 * 随机获取一条数据
	 * @return
	 */
	@ApiOperation(value = "随机获取一条数据")
	@GetMapping("/getRandOne")
	public AjaxResult getRandOne() {
		String phone = "";
		PhoneList randOne = phoneListService.getRandOne();
		phone = randOne.getPhone();
		// 删除
		phoneListService.removeById(randOne.getId());
		return AjaxResult.success(phone);
	}
}
